package com.bys.factory;

import com.bys.service.PayService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class PayFactory implements FallbackFactory<PayService> {
    @Override
    public PayService create(Throwable e) {
        return new PayService() {
            @Override
            public String feignOk() {
                System.out.println(e.getMessage());
                String result = "服务繁忙, 请稍后再试！！ **** ok ****";
                return result + Thread.currentThread().getName();
            }

            @Override
            public String feign_timeout() {
                System.out.println(e.getMessage());
                String result = "服务繁忙, 请稍后再试！！ **** timeout ****";
                return result + Thread.currentThread().getName();
            }

            @Override
            public String feign_err() {
                System.out.println(e.getMessage());
                String result = "服务繁忙, 请稍后再试！！ **** err ****";
                return result + Thread.currentThread().getName();
            }
        };
    }
}
